package cn.iocoder.yudao.module.system.controller.app.passengerinfo;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.system.controller.app.passengerinfo.vo.PassengerComprehensiveVO;
import cn.iocoder.yudao.module.system.service.passengerinfo.PassengerInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户 APP - 乘客信息")
@RestController("appPassengerInfoController")
@RequestMapping("/system/passenger-info")
@Validated
public class PassengerInfoController {

    @Resource
    private PassengerInfoService passengerInfoService;

    @GetMapping("/get-my-comprehensive")
    @Operation(summary = "获取我的乘客综合信息")
    public CommonResult<PassengerComprehensiveVO> getMyPassengerComprehensiveInfo() {
        // 从当前登录用户中获取userId
        Long userId = SecurityFrameworkUtils.getLoginUserId();
        
        // 调试信息
        System.out.println("APP端获取乘客综合信息 - userId: " + userId);
        
        if (userId == null) {
            throw new RuntimeException("用户未登录");
        }
        
        PassengerComprehensiveVO result = passengerInfoService.getMyPassengerComprehensiveInfo(userId);
        return success(result);
    }

}
